import { message } from 'antd';
import { savePwd } from '@/services/mySettings';
export default {
  namespace: 'modifyPwd',
  state: { msg: {} },
  effects: {
    *setPwd({ payload }, { call, put }) {
      try {
        const res = yield call(savePwd, payload);
        console.log('提交结果：', res);
        console.log('--提交结果：', res.code, +res.code === 0);
        if (+res.code === 0) {
          message.success('保存成功！');
        } else {
          message.error(res.message);
        }
      } catch (e) {
        console.log(e);
        message.error('保存失败，请稍后再试');
      }
    },
  },
  reducers: {
    setData(state, { payload }) {
      const newState = {
        ...state,
        ...payload,
      };
      return newState;
    },
  },
};
